package com.ruoyi.cbs.contract.service.impl;

import java.util.List;

import com.ruoyi.cbs.contract.domain.ContractorPersonnel;
import com.ruoyi.cbs.contract.mapper.ContractorPersonnelMapper;
import com.ruoyi.cbs.contract.service.IContractorPersonnelService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 承包商人员Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-10-31
 */
@Service
public class ContractorPersonnelServiceImpl implements IContractorPersonnelService
{
    @Autowired
    private ContractorPersonnelMapper contractorPersonnelMapper;

    /**
     * 查询承包商人员
     * 
     * @param id 承包商人员主键
     * @return 承包商人员
     */
    @Override
    public ContractorPersonnel selectContractorPersonnelById(Long id)
    {
        return contractorPersonnelMapper.selectContractorPersonnelById(id);
    }

    /**
     * 查询承包商人员列表
     *
     * @param contractorId 承包商ID
     * @return 承包商人员列表
     */
    @Override
    public List<ContractorPersonnel> selectListByContractorId(Long contractorId)
    {
        ContractorPersonnel contractorPersonnel = new ContractorPersonnel();
        contractorPersonnel.setContractorId(contractorId);
        return selectContractorPersonnelList(contractorPersonnel);
    }

    /**
     * 查询承包商人员列表
     * 
     * @param contractorPersonnel 承包商人员
     * @return 承包商人员
     */
    @Override
    public List<ContractorPersonnel> selectContractorPersonnelList(ContractorPersonnel contractorPersonnel)
    {
        return contractorPersonnelMapper.selectContractorPersonnelList(contractorPersonnel);
    }

    /**
     * 新增承包商人员
     * 
     * @param contractorPersonnel 承包商人员
     * @return 结果
     */
    @Override
    public int insertContractorPersonnel(ContractorPersonnel contractorPersonnel)
    {
        contractorPersonnel.setCreateTime(DateUtils.getNowDate());
        contractorPersonnel.setId(IdFactory.newLongId());
        if (contractorPersonnel.getCreateBy() == null) {
            contractorPersonnel.setCreateBy("admin");
        }
        return contractorPersonnelMapper.insertContractorPersonnel(contractorPersonnel);
    }

    /**
     * 修改承包商人员
     * 
     * @param contractorPersonnel 承包商人员
     * @return 结果
     */
    @Override
    public int updateContractorPersonnel(ContractorPersonnel contractorPersonnel)
    {
        contractorPersonnel.setUpdateTime(DateUtils.getNowDate());
        contractorPersonnel.setUpdateBy(SecurityUtils.getUsername());
        return contractorPersonnelMapper.updateContractorPersonnel(contractorPersonnel);
    }

    /**
     * 批量删除承包商人员
     * 
     * @param ids 需要删除的承包商人员主键
     * @return 结果
     */
    @Override
    public int deleteContractorPersonnelByIds(Long[] ids)
    {
        return contractorPersonnelMapper.deleteContractorPersonnelByIds(ids);
    }

    /**
     * 删除承包商人员信息
     * 
     * @param id 承包商人员主键
     * @return 结果
     */
    @Override
    public int deleteContractorPersonnelById(Long id)
    {
        return contractorPersonnelMapper.deleteContractorPersonnelById(id);
    }
}
